<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<button id="all">全选</button>
<button id="reverse">反选</button>
<button id="cancel">取消</button>
<table border="1">
   <thead>
    <tr>
        <th>#</th>
        <th>姓名</th>
        <th>爱好</th>
    </tr>
   </thead>
    <tbody>
    <tr>
        <td><input type="checkbox"></td>
        <td>金老板</td>
        <td>开车</td>
    </tr>
    <tr>
        <td><input type="checkbox"></td>
        <td>景女神</td>
        <td>茶道</td>
    </tr>
    <tr>
        <td><input type="checkbox"></td>
        <td>苑昊（苑局）</td>
        <td>不洗头、不翻车、不要脸</td>
    </tr>
    </tbody>
</table>


</body>
<script src="jquery.js"></script>

<script>
    // 全选
    $('#all').click(function () {
      $(':checkbox').prop('checked',true);

    });
    // 取消
    $('#cancel').click(function () {
      $(':checkbox').prop('checked',false);

    });

    // 反选
    $('#reverse').click(function () {

      // $(':checked').prop('checked',false);
      // $('input:not(:checked)').prop('checked',true);
       var all = $(':checkbox');

       for (var i=0;i<all.length;i++){
           var one = all.eq(i);
           var status = one.prop('checked');
           // if (status){
           //     one.prop('checked',false);
           // }else {
           //     one.prop('checked',true);
           // }
           one.prop('checked',!status);

       }


    });



</script>


</html>